#include "Database.h"

/*********************************
BEGIN aquiring items from Catalyst
**********************************/
std::list<std::string> Database::AquireItemList(std::string level1Node) {
	return Catalyst::Instance().GetChildren(level1Node);
}
/*******************************
END aquiring items from Catalyst
********************************/

/*************************
BEGIN setter for buildings
**************************/
void Database::SetBuildings()
{
	buildings = AquireItemList("buildings");
}
/***********************
END setter for buildings
************************/

/*************************
BEGIN getter for buildings
**************************/
void Database::GetBuildings()
{
	ListItems(buildings);
}
/***********************
END getter for buildings
************************/

/*********************
BEGIN setter for units
**********************/
void Database::SetUnits()
{
	units = AquireItemList("units");
}
/*******************
END setter for units
********************/

/*********************
BEGIN getter for units
**********************/
void Database::GetUnits()
{
	ListItems(units);
}
/*******************
END getter for units
********************/

/**********************
BEGIN listing buildings
***********************/
void Database::ListItems(std::list<std::string> itemList) {
	std::list<std::string>::iterator iter;
	for (iter = itemList.begin(); iter != itemList.end(); ++iter) {
		std::cout << *iter <<std::endl;
	}
}
/********************
END listing buildings
*********************/

/******************************
BEGIN importing XML in Catalyst
*******************************/
Database::Database() {
	Catalyst::Instance().LoadXmlFile("Catalyst.xml");
	Catalyst::Instance().GoLower("buildings");
	Catalyst::Instance().GoLower("building","name","House");
	Catalyst::Instance().AttrVal("hp");
	Catalyst::Instance().GoHigher();
	Catalyst::Instance().GoLower("building");
	Catalyst::Instance().GoLower("costs");
	Catalyst::Instance().GoHigher();
	Catalyst::Instance().GoHigher();
	Catalyst::Instance().GoHigher();
}
/****************************
END importing XML in Catalyst
*****************************/